WalkerCryptoTest.AESFileEcryptorTest
Encrypts a file before decrypting it.
public async Task<string> AESFileEcryptorTest()
{
var password = "ShadowLord".ToSecureData();
string inputFilePath = @"TestFiles\finally-all-the-chin-woo-artworks-in-high-quality-v0-tgmaxu5u03oe1.png";
string encryptedFilePath = @"TestFiles\finally-all-the-chin-woo-artworks-in-high-quality-v0-tgmaxu5u03oe1_encrypted.png";
string decryptedFilePath = @"TestFiles\finally-all-the-chin-woo-artworks-in-high-quality-v0-tgmaxu5u03oe1_decrypted.png";
// Encrypt the file and report progress to the console
double encryptionProgress = 0.0;
await AESFileEncryptor.EncryptFileAsync(inputFilePath, encryptedFilePath, password, progress =>
{
encryptionProgress = progress;
Console.WriteLine("Encryption Progress: " + (progress * 100) + "%");
});
Console.WriteLine("Encrypted file saved at: " + Path.GetFullPath(encryptedFilePath));
// Decrypt the file and report progress to the console
double decryptionProgress = 0.0;
Console.WriteLine("Starting file decryption...");
await AESFileEncryptor.DecryptFileAsync(encryptedFilePath, decryptedFilePath, password, progress =>
{
decryptionProgress = progress;
Console.WriteLine("Decryption Progress: " + (progress * 100) + "%");
});
Console.WriteLine("Decrypted file saved at: " + Path.GetFullPath(decryptedFilePath));
Console.WriteLine(Environment.NewLine);
Console.WriteLine(Environment.NewLine);
return "Done";
}